\section*{Exceptions}
  {\it Elib} wraps exception, which can be thrown during its usage, in $ ElibException$ class.
  $ElibExceptions$ thrown during using of {\it Elib} can be caused by other exception.
  For example, an $System.TimeoutException$ is thrown if a program tries to connect to port, 
  which is already owned by another process.
  In {\it Elib} such situation can happens and {\it Elib} wraps this exception
  with $SerialPortException$, which is inherited from $ElibException$.
  The original $System.TimeoutException$ can be retrieved from $InnerException$ property.
  See Figure~\ref{exceptionuse}.

\begin{figure}[!hbp]
\begin{lstlisting}
//in Elib all exception are caught like this exemplary exception
try {
  throw new ApplicationException("My exemplary exception");
} catch (ApplicationException e){
  throw new ElibException("Just an example", e);
}
//........................................................................
//retrieving original exception after catching the ElibException
try {
  //...some functions which use Elib and 
  // which throws new ApplicationException("My model exception")
} catch (ElibException e) {
  Console.WriteLine(e.InnerException.Message);
}
\end{lstlisting}
\caption{How to retrieve the original exception?}
\label{exceptionuse}
\end{figure}

  In the example there is shown how every single exception is wrapped 
  and thrown again in {\it Elib}.
  There is also depicted a way how to extract the original exception.
  The code, which catch exceptions from {\it Elib} would print following output:
\begin{verbatim}
  My model exception
\end{verbatim}

  The following snippet illustrates the structure of {\it Elib's} exceptions and
  introduces all inherited subclasses.
  The subclasses serves to differentiate the {\it Elib's} exceptions.
\begin{lstlisting}
// The ElibException is thrown, if an unusual situation happens in Elib.
// It wraps all other exceptions, which are thrown from Elib
public class ElibException : Exception { 
  //Only constructors are implemented
}
// The TimeoutElibException is thrown if the "End" function implementing IAsyncResult was called 
// and indicates that the answer to command has not been delivered in time.
public class TimeoutElibException : ElibException { 
  //Only constructors are implemented
}
// If SerialPort throws any exception, than this exception wraps the original exception.
// After that the SerialPortException is thrown.
public class SerialPortException : ElibException {
  //Only constructors are implemented
}
// ArgsException is thrown if wrong arguments are passed to a function in Elib.
public class ArgsException : ElibException {
  //Only constructors are implemented
}
// Thrown if command to e-Puck has nonsense values.
public class CommandArgsException : ArgsException {
  //Only constructors are implemented
}
// Thrown if session with e-Puck has not started or has already ended.
public class UnconnectedException : ElibException {
  //Only constructors are implemented
}

\end{lstlisting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
